package rm.metrology.shared;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ValidationException extends RuntimeException {

	private static final long serialVersionUID = 1L;

	private List<String> errors = new ArrayList<String>();
	
	public ValidationException() {
		super("Validation Exceptions: Use 'addError' and 'getErrors' methods!");
	}
	
	public void addError(Object failedValue, String msg) {
		msg = ((failedValue == null) ? "null" : failedValue) + " :: " + msg;
		errors.add(msg);
	}
	
	public List<String> getErrors() {
		return Collections.unmodifiableList(errors);
	}
	
}
